$(document).ready(function() {	
	$("#frmAdd").validate({
		errorClass		: 'error',
		errorElement	: 'span',
		onfocusout		: false,
		onkeyup			: false,
		ignore			: "input[type='text']:hidden",
		rules: {
			pcontroller: {
				required			: true,
				validController		: true
			},
			paction: {
				required			: true,
				validAction			: true
			},
			pname: {
				required			: true,
				minlength			: VL_NAME_MINLENGTH
			},
			ptitle: {
				required			: true
			},
			pkeywords: {
				required			: true
			},
			pdescription: {
				required			: true,
				maxlength			: VL_SHORT_MAXLENGTH
			}
		},
		messages: {	
			pcontroller: {
				required			: controller_required,
				validController		: controller_invalid
			},
			paction: {
				required			: action_required,
				validAction			: action_invalid
			},
			pname: {
				required			: name_required,
				minlength			: name_minlength
			},
			ptitle: {
				required			: title_required
			},
			pkeywords: {
				required			: keywords_required
			},
			pdescription: {
				required			: description_required,
				maxlength			: description_maxlength
			}
		},
		errorPlacement: function(label, element) {			
			var id = element.attr('id');	
			label.insertAfter($('#' + id));			
		},
		submitHandler: function(form) {				
			form.submit();
		}
	});	
	$.validator.addMethod('validController',function(){
		var strController = $('#pcontroller').val();										 
		return validateCode(strController);
	});
	$.validator.addMethod('validAction',function(){
		var strAction = $('#paction').val();										 
		return validateCode(strAction);											 
	});
});